package com.heima.wemedia.controller.v1;

import com.heima.apis.article.IArticleClient;
import com.heima.apis.comment.ICommentClient;
import com.heima.model.article.dtos.ArticleCommonDto;
import com.heima.model.comment.dtos.ALLCommentListDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentListDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.WmCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author JianKang
 * @create 2023-11-06 15:04
 */
@RestController
@RequestMapping("/api/v1/comment/manage")
@Slf4j
public class WmCommentController {

    @Autowired
    ICommentClient commentClient;

    @Autowired
    IArticleClient articleClient;

    @Autowired
    WmCommentService wmCommentService;

    @DeleteMapping("del_comment/{commentId}")
    public ResponseResult delComment(@PathVariable String commentId) {
        return commentClient.delComment(commentId);
    }

    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delCommentRepay(@PathVariable String commentRepayId) {
        return commentClient.delCommentRepay(commentRepayId);
    }

    @PostMapping("/comment_repay")
    public ResponseResult commentRepay(@RequestBody CommentRepaySaveDto dto) {
        return wmCommentService.commentRepay(dto);
    }

    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody ArticleCommonDto dto) {
        return articleClient.updateCommentStatus(dto);
    }

    @PostMapping("/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody ALLCommentListDto dto) {
        log.info("findNewsComments:{}", dto);
        return articleClient.findNewsComments(dto);
    }

    @PostMapping("/list")
    public ResponseResult findCommentList(@RequestBody CommentListDto dto) {
        return wmCommentService.findCommentList(dto);
    }

    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return wmCommentService.like(dto);
    }
}
